#include "gmock.h"

#include "Logger.h"
static std::string str = "";

ACTION(LOGOPEN){
	str += "OPEN "; std::cout << std::endl << str << std::endl;
}

class Mocker : public File{
public :
	MOCK_METHOD0(is_open,bool());
	MOCK_CONST_METHOD0(good,bool());
	MOCK_METHOD1(open,void(const char* ));
	MOCK_METHOD1(open,void(const wchar_t*));
	MOCK_METHOD1(open,void(const int));


};

TEST(LOGGERTEST, TEST){
	Mocker global;
	Logger log("log","TEST",0);
	EXPECT_CALL(global,is_open()).WillRepeatedly(::testing::Return(true));
	EXPECT_CALL(global,good()).Times(2);
	EXPECT_CALL(global,open((wchar_t*)"NO"));
	EXPECT_CALL(global,open((const char*)"NO"));
	log.SetPLogFile(&global);
	log.LogPrintf("TEST MESSAGE");

}

TEST(LOGGERTEST,TEST1){
	Mocker global;
	Logger log("log","TEST",0);
	::testing::InSequence obj;
	EXPECT_CALL(global,is_open()).WillOnce(::testing::Return(false));
	EXPECT_CALL(global,good()).WillOnce(::testing::Return(true));
	EXPECT_CALL(global,open(::testing::SafeMatcherCast<const char*>(::testing::_)));
	EXPECT_CALL(global,is_open()).WillOnce(::testing::Return(true));
	EXPECT_CALL(global,good()).WillOnce(::testing::Return(true));
	EXPECT_CALL(global,is_open()).WillOnce(::testing::Return(true));
	log.SetPLogFile(&global);
	log.LogPrintf("TEST MESSAGE");
}


TEST(LOGGERTEST,TESTCUSTOMACTION){


	Mocker global;
	Logger log("dir","NO",0);
	EXPECT_CALL(global,is_open()).WillOnce(::testing::Return(false));
	EXPECT_CALL(global,good()).WillRepeatedly(::testing::Return(true));
	ON_CALL(global,open(::testing::SafeMatcherCast<const char*>(::testing::_))).WillByDefault(LOGOPEN());
	log.SetPLogFile(&global);
	log.Change("NO");
	log.GetIPID();
}
